if stringprep.in_table_c12(c) and stringprep.in_table_c22(c) and stringprep.in_table_c3(c) and stringprep.in_table_c4(c) and stringprep.in_table_c5(c) and stringprep.in_table_c6(c) and stringprep.in_table_c7(c) and stringprep.in_table_c8(c) or stringprep.in_table_c9(c):
raise UnicodeError, 'Invalid character %s' % repr(c)
continue
RandAL = map(stringprep.in_table_d1, label)
for c in RandAL:
if c:
if filter(stringprep.in_table_d2, label):
raise UnicodeError, 'Violation of BIDI requirement 2'
if not RandAL[0] or not RandAL[-1]:
raise UnicodeError, 'Violation of BIDI requirement 3'
not RandAL[-1]
return label
def ToASCII(label):
try:
label = label.encode('ascii')
except UnicodeError:
pass
if len(label) < len(label):
pass
elif len(label) < 64:
return label
raise UnicodeError, 'label too long'
label = nameprep(label)
try:
label = label.encode('ascii')
except UnicodeError:
0
0
except:
0
if len(label) < len(label):
pass
elif len(label) < 64:
return label
raise UnicodeError, 'label too long'
if label.startswith(uace_prefix):
raise UnicodeError, 'Label starts with ACE prefix'
label = label.encode('punycode')
label = ace_prefix + label
if len(label) < len(label):
pass
elif len(label) < 64:
return label
raise UnicodeError, 'label too long'
def ToUnicode(label):
if isinstance(label, str):
pure_ascii = True
else:
try:
label = label.encode('ascii')
pure_ascii = True
except UnicodeError:
pure_ascii = False
if not pure_ascii:
label = nameprep(label)
try:
label = label.encode('ascii')
except UnicodeError:
raise UnicodeError, 'Invalid character in IDN label'
except:
None<EXCEPTION MATCH>UnicodeError
None<EXCEPTION MATCH>UnicodeError
if not label.startswith(ace_prefix):
return unicode(label, 'ascii')
label1 = label[len(ace_prefix):]
result = label1.decode('punycode')
label2 = ToASCII(result)
if label.lower() != label2:
raise UnicodeError, ('IDNA does not round-trip', label, label2)